1. Field of the Invention
Apparatuses and methods consistent with the present invention relate to an apparatus for providing atomicity with respect to a request of a write operation for successive sectors in a flash memory. More particularly, the present invention relates to an apparatus for providing atomicity with respect to a request of a write operation for successive sectors in a flash memory and a method of providing the same, in which a data write progress status of sectors is separately displayed during a write operation for one or more successive sectors in the flash memory, and even when power supply is interrupted during a data write operation, atomicity for the write operation for one or more successive sectors is ensured on the basis of the separately displayed data write progress status so as to minimize the lowering in the performance of a system.
2. Description of the Related Art
In recent years, a flash memory has been widely used in various applications, such as an embedded system, a mobile device, and the like, because it is nonvolatile like a hard disk, and has high access speed and low power consumption.
A flash memory based system includes a RAM that is a volatile memory, a controller in which a CPU is built, and a flash memory that is a non-volatile memory. In this flash memory based system, since abrupt power interrupt may occur often due to characteristics of the application fields, file systems used in this system need to be transactional.
However, according to a general method of using a flash memory, in a case where a write operation is performed in the flash memory, even if various actions that belong to one transaction are completed without an error or an error occurs in the various actions, it is not possible to ensure atomicity in which the error is processed without abnormality in the data. As a result, in order to provide a transaction function, a large amount of overhead is required in the file systems.
Meanwhile, when power is interrupted during a write operation for one or more successive sectors in the flash memory, a portion of data sectors that request a write operation may be programmed, and the other portion may not be programmed.
FIG. 1 is a diagram illustrating a structure of a flash memory device according to the related art.
A flash memory device 100 includes a plurality of blocks 110, and each of the blocks 110 becomes a unit of an erasing operation of the flash memory.
Further, each of the blocks 110 includes a plurality of pages 111, and each of the pages 111 becomes a unit of read and write operations in the flash memory.
An operating system performs a read/write request in a sector unit, and the page 111 of the flash memory is equal to a size of a sector or has a size that corresponds to any multiple of the size of the sector.
FIG. 2 is a diagram illustrating a write operation for one or more successive sectors executed in the flash memory shown in FIG. 1.
According to the related art, in order to indicate the fact that a program is normally completed, as shown in FIG. 2, a status bit 202 is allocated for each sector 201, and an initial value of the status bit 202 has a value of an invalid mark 0x1 (see reference numeral 202a).
When a program for a corresponding sector is completed without power interruption, a status bit has a value of a valid mark 0x0 (see reference numeral 202b).
FIG. 3 is a flowchart illustrating a process of a write operation for one or more successive sectors according to the related art.
After data is written in the sectors (Step S301), in order to indicate the fact that a program for the sectors is completed without power interrupt, a valid mark 0x0 indicating the fact that a corresponding sector is valid is programmed in a status bit of the sector (Step S302).
For reference, if an initial value of the status bit has a value of an invalid mark 0x1, a value of a valid mark, 0x0 is written.
After the process of Step S302, it is checked whether there remains a sector for data to be written (Step S303), and as a result of the check, if data is written in all of the sectors, the process is completed.
As the result of the check, if there remains a sector to be written, the process of Step S301 is repeated.
In the embodiment shown in FIG. 2 where data is written in six sectors including logical sectors 1 to 6, in Step S302, data is written in the logical sector 1 and a valid mark is displayed in a status bit corresponding to the logical sector 1. Then, data is written in the logical sector 2, and a valid mark is displayed in a status bit corresponding to the logical sector 2.
In the same manner, data is written in the logical sectors 3 to 6, and a valid mark is displayed in a status bit of each of the sectors.
FIG. 4 is a flowchart illustrating a process of inspecting validity of sectors in a write operation for one or more successive sectors according to the related art.
In the validity inspection of the sectors where the data is written, it is first determined whether a status bit of a sector is “1” (Step S401). At this time, if the status bit of the corresponding sector is not “1”, it may be assumed that the corresponding sector is determined as a valid sector, and a sector program is completed (Step S402).
As a result of the process of Step S401, if the status bit of the sector is “1”, it is assumed that the corresponding sector is determined as an invalid sector, and the sector program is not completed (Step S403).
As described above, the following problems exist in the related art. When power interrupt occurs during a write operation for one or more successive sectors, a portion of the sectors may be determined as valid sectors, and a portion of the sectors may be determined as invalid sectors. As a result, it is not possible to ensure atomicity for a write operation for one or more successive sectors.